package giermala.dominik.fotka.dao;

import giermala.dominik.fotka.domain.Foto;

import java.util.List;

import javax.persistence.TypedQuery;

import org.springframework.stereotype.Repository;

@Repository
public class FotoDao extends AbstractJpaDao<Foto> implements IFotoDao {
	
	public FotoDao(){
	      setClazz(Foto.class );
	}

	public List<Foto> find2RandomFotos() {
		TypedQuery<Foto> query = entityManager.createQuery("from Foto order by random()", Foto.class);
		query.setMaxResults(2);
		return query.getResultList();
	}
}